<?php

namespace app\api\controller\v1;

use app\common\controller\Api;

/**
 * 学校
 *
 * Class School
 * User zhenzihan
 * Date 2020/6/15
 * @package app\api\controller\v1
 */
class School extends Api
{
    /**
     * 学期列表
     *
     * @User zhenzihan
     * @Date 2020/6/15
     *
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function semester()
    {
        $id = $this->request->request('id', 0);
        $list = \app\common\model\Semester::where('school_id', $id)->whereTime('end_date', '>', time())->select();

        foreach ($list as $key => &$value) {
            $value['list'] = \app\common\model\Semester::getWeekList($value->start_date, $value->end_date);
        }

        $this->success('', $list);
    }
}
